package org.lboot.llog.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Column;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import java.util.Date;

/**
 * @author kindear
 * 日志数据传输对象
 */
@Data
@ApiModel(value = "日志DTO")
public class ApiLogDTO {
    @ApiModelProperty(value = "追踪ID")
    String traceId;

    @NotBlank(message = "服务名称不可为空")
    @ApiModelProperty(value = "服务名称",example = "鉴权服务")
    String serviceName;

    @NotBlank(message = "服务地址不可为空")
    @ApiModelProperty(value = "服务地址",example = "http://10.10.10.10:8843")
    String serviceHost;

    @NotBlank(message = "功能模块不可为空")
    @ApiModelProperty("功能模块")
    String module;

    @NotBlank(message = "接口名称不可为空")
    @ApiModelProperty("接口名称")
    String apiName;

    @NotBlank(message = "方法名不可为空")
    @ApiModelProperty("方法名")
    String method;

    @ApiModelProperty("方法类路径")
    String clazz;

    @ApiModelProperty("请求参数")
    String params;

    @ApiModelProperty("返回数据")
    String returnData;

    @NotBlank(message = "操作不可为空")
    @ApiModelProperty("操作")
    String action;

    // 执行失败设置为 0
    @Min(0)
    @Max(1)
    @ApiModelProperty("请求状态")
    Integer status;


    @NotBlank(message = "操作用户ID不可为空")
    @ApiModelProperty("操作用户ID")
    String operatorId;


    @ApiModelProperty("客户端请求IP")
    String clientIp;

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "操作开始时间",name = "startTime")
    private Date startTime;


    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "操作结束时间",name = "endTime")
    private Date endTime;


    @ApiModelProperty("耗费时长")
    private Integer totalTime;
}
